<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no" />
		<title></title>
		<style type="text/css">
			*{
				margin: 0px;
				padding: 0px;
			}
			html,
			body{
				height: 100%;
				overflow: hidden;
			}
			.wrap{
				height: 100%;
				background-color: gray;
				perspective: 200px;
			}
			.wrap > .inner{
				height: 100%;
				transform-style: preserve-3d;
			}
			.wrap > .inner > img{
				width: 30%;
				margin-top: -40px;
				animation: move 2s linear infinite;
			}
			.wrap > .inner > img,
			.wrap > .inner > p{
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translate3d(-50%, -50%, 0);
			}
			@keyframes move{
				from{
					transform: translate3d(-50%, -50%, 0) rotateY(0deg);
				}
				to{
					transform: translate3d(-50%, -50%, 0) rotateY(360deg);
				}
			}
		</style>
	</head>
	<body>
		<div class="wrap">
			<div class="inner">
				<img src="images/logo2.png" alt="这是一个加载图片" />
				<p>已加载0%</p>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		window.onload = function () {
			var pNode = document.querySelector(".wrap > .inner > p");
			var flag = 0;
			var arr = [];
			for (item in imgData) {
				arr = arr.concat(imgData[item]);
			}
			for (var i = 0; i < arr.length; i++) {
				var img = new Image();
				// 正常来说加载这里要写 ajax 请求
				img.src = arr[i];
				img.onload = function () {
					flag++;
					pNode.innerHTML = "已加载 " + (Math.round(i / arr.length * 100)) + "%";
				}
				img.onerror = function () {
					console.log("地址有问题");
				}
			}
		}
	</script>
</html>
